from django.db import models


# Create your models here.

# 博客作者
class Author(models.Model):
    SEX = [('F', 'Female'), ('M', 'Male')]

    name = models.CharField(max_length=10, null=False, default="佚名", verbose_name="作者")
    sex = models.CharField(max_length=1, choices=SEX)
    idcard_no = models.CharField(max_length=18, unique=True, null=False)


class Article(models.Model):
    TYPE = [('0', '原创'), ('1', '转载'), ('2', '翻译')]
    title = models.CharField(max_length=255, null=False, default="未命名")

    content = models.TextField()
    create_dt = models.DateTimeField(auto_now_add=True)
    update_time = models.DateTimeField(auto_now=True)
    article_type = models.CharField(max_length=1, choices=TYPE)
    author = models.ForeignKey(Author, on_delete=models.CASCADE)
